package com.ruoyi.xiaoshou.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.xiaoshou.domain.SaleBackDetail;
import com.ruoyi.xiaoshou.service.ISaleBackDetailService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 销售退货详情Controller
 * 
 * @author lmj
 * @date 2024-10-29
 */
@RestController
@RequestMapping("/saleBackDetail")
public class SaleBackDetailController extends BaseController
{
    @Autowired
    private ISaleBackDetailService saleBackDetailService;

    /**
     * 查询销售退货详情列表
     */
    @RequiresPermissions("xiaoshou:saleBackDetail:list")
    @GetMapping("/list")
    public TableDataInfo list(SaleBackDetail saleBackDetail)
    {
        startPage();
        List<SaleBackDetail> list = saleBackDetailService.selectSaleBackDetailList(saleBackDetail);
        return getDataTable(list);
    }
    @RequiresPermissions("xiaoshou:saleBackDetail:list")
    @RequestMapping("/useList")
    public TableDataInfo useList(SaleBackDetail saleBackDetail)
    {
        startPage();
        List<SaleBackDetail> list = saleBackDetailService.useSaleBackDetailList(saleBackDetail);
        return getDataTable(list);
    }

    /**
     * 导出销售退货详情列表
     */
    @RequiresPermissions("xiaoshou:saleBackDetail:export")
    @Log(title = "销售退货详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SaleBackDetail saleBackDetail)
    {
        List<SaleBackDetail> list = saleBackDetailService.selectSaleBackDetailList(saleBackDetail);
        ExcelUtil<SaleBackDetail> util = new ExcelUtil<SaleBackDetail>(SaleBackDetail.class);
        util.exportExcel(response, list, "销售退货详情数据");
    }

    /**
     * 获取销售退货详情详细信息
     */
    @RequiresPermissions("xiaoshou:saleBackDetail:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(saleBackDetailService.selectSaleBackDetailById(id));
    }

    /**
     * 新增销售退货详情
     */
    @RequiresPermissions("xiaoshou:saleBackDetail:add")
    @Log(title = "销售退货详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SaleBackDetail saleBackDetail)
    {
        return toAjax(saleBackDetailService.insertSaleBackDetail(saleBackDetail));
    }

    /**
     * 修改销售退货详情
     */
    @RequiresPermissions("xiaoshou:saleBackDetail:edit")
    @Log(title = "销售退货详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SaleBackDetail saleBackDetail)
    {
        return toAjax(saleBackDetailService.updateSaleBackDetail(saleBackDetail));
    }

    /**
     * 删除销售退货详情
     */
    @RequiresPermissions("xiaoshou:saleBackDetail:remove")
    @Log(title = "销售退货详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(saleBackDetailService.deleteSaleBackDetailByIds(ids));
    }
}
